package jp.co.systemi.asp.workflow.data;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.CreationDate;
import org.slim3.datastore.CreationUser;
import org.slim3.datastore.Model;
import org.slim3.datastore.ModificationDate;
import org.slim3.datastore.ModificationUser;

import com.google.appengine.api.datastore.Key;
@Model
public class PaidHoliday implements Serializable{
    private static final long serialVersionUID = -7034730428724555505L;
    @Attribute(primaryKey = true)
    private Key id;
    private String loginId;			//　申請者
    private Date startDate;
    private Date endDate;
    private Double days;		//　日数
    private String memo;
    private Common.APPLY_STATUS status;
    // 申請中の分を含まない、承認される時点で、確定として、残日数を減らす
    // 申請画面を表示するときに、申請分を減らして、画面に表示する
    private Double remainingDays;	// 残日数、新年度増加、持ち越し、失効の処理を行う（管理者画面/バッチ）

    private Date initDate; 			// 初期設定日付
    private Integer initDays;		// 初期有給日数
    private Key refId;				// 取消、変更の場合の参照元
    private Key applyId;			// 申請番号

    @Attribute(listener = CreationDate.class)
    private Date regDate = null;
    @Attribute(listener = CreationUser.class)
    private com.google.appengine.api.users.User regUser;
    @Attribute(listener = ModificationDate.class)
    private Date updDate = null;
    @Attribute(listener = ModificationUser.class)
    private com.google.appengine.api.users.User updUser;

    // 保存しない項目
    @Attribute(persistent = false)
    private Boolean select;
    @Attribute(persistent = false)
    private Integer seq;
    @Attribute(persistent = false)
    private String userName;

    public com.google.appengine.api.users.User getRegUser() {
        return regUser;
    }

    public void setRegUser(com.google.appengine.api.users.User user) {
        this.regUser = user;
    }

    public void setUpdUser(com.google.appengine.api.users.User updUser) {
        this.updUser = updUser;
    }

    public com.google.appengine.api.users.User getUpdUser() {
        return updUser;
    }

    public Key getId() {
        return id;
    }

    public void setId(Key id) {
        this.id = id;
    }
    public Date getRegDate() {
        return regDate;
    }

    public void setRegDate(Date regDate) {
        this.regDate = regDate;
    }

    public Date getUpdDate() {
        return updDate;
    }

    public void setUpdDate(Date updDate) {
        this.updDate = updDate;
    }
    public Boolean getSelect() {
        return select;
    }

    public void setSelect(Boolean select) {
        this.select = select;
    }

    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }
    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Double getDays() {
        return days;
    }

    public void setDays(Double days) {
        this.days = days;
    }

    public Common.APPLY_STATUS getStatus() {
        return status;
    }

    public void setStatus(Common.APPLY_STATUS status) {
        this.status = status;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public Double getRemainingDays() {
        return remainingDays;
    }

    public void setRemainingDays(Double remainingDays) {
        this.remainingDays = remainingDays;
    }

    public Date getInitDate() {
        return initDate;
    }

    public void setInitDate(Date initDate) {
        this.initDate = initDate;
    }

    public Integer getInitDays() {
        return initDays;
    }

    public void setInitDays(Integer initDays) {
        this.initDays = initDays;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public Key getRefId() {
        return refId;
    }

    public void setRefId(Key refId) {
        this.refId = refId;
    }

    public Key getApplyId() {
        return applyId;
    }

    public void setApplyId(Key applyId) {
        this.applyId = applyId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String toString(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        return sdf.format(startDate) + "～" + sdf.format(endDate) + " " + days + "日間";
    }
}
